import pexpect
 
def su(command, password): 
    child = pexpect.spawn('su -c "' + command + '"')
    choice = child.expect(['Password:'])
    child.sendline(password)
    choice = child.expect(['su: Authentication failure' ,pexpect.EOF])
    if choice == 0:
	return False
    return True
